'''
Created on May 16, 2010

iur - Universal Web Remote targetted for iphone
Copyright (C) 2010 forteresce@gmail.com

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 3
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

'''

import unittest
from player.rhythmbox import RhythmboxEventHandler, RhythmboxCollectionHandler

class RhythmboxTest(unittest.TestCase):
    
    def setUp(self):
        self.playerEventHandler = RhythmboxEventHandler()
        self.playerCollectionHandler = RhythmboxCollectionHandler()


    def tearDown(self):
        self.playerEventHandler = None

    def testPlay(self):
        self.playerEventHandler.play()

    def testPause(self):
        self.playerEventHandler.pause()

    def testNext(self):
        self.playerEventHandler.next()

    def testPrevious(self):
        self.playerEventHandler.prev()
        
    def testGetCurrentSong(self):
        print(self.playerEventHandler.getCurrentSong())

    def testVolumeUp(self):
        self.playerEventHandler.volumeUp()

    def testVolumeDown(self):
        self.playerEventHandler.volumeDown()
        
    def testGetAlbums(self):
        albums = self.playerCollectionHandler.getAlbums()
        
        self.assertTrue(len(albums) > 0)
        print(albums[0])
        
    def testGetSongsInAlbum(self):
        album = self.playerCollectionHandler.getAlbums()[0]
        songs = self.playerCollectionHandler.getSongsInAlbum(album.id)
        
        self.assertTrue(len(songs) > 0)
        print(songs[0])

    def testaddSongToQueue(self):
        album = self.playerCollectionHandler.getAlbums()[0]
        songs = self.playerCollectionHandler.getSongsInAlbum(album.id)
        self.playerEventHandler.addSongToQueue(songs[0].id)

if __name__ == "__main__":
    #import sys;sys.argv = ['', 'RhythmboxTest.testName']
    unittest.main()